<script lang="ts" setup>
import { useRouter } from 'vue-router'
import { wantStore } from '../../stores/want'

const { pList } = defineProps(['pList'])
const wantPinias = wantStore()

const delWantBtn = (mid:string) => {
    wantPinias.delWantList(mid)
}

</script>

<template>
    <van-swipe-cell>
        <div class="want-play-item" @click="$router.push({name:'playDetail',params: {pid: pList.id}})">
            <img :src="pList?.img">
            <div class="con">
                <div class="name">{{ pList?.nm }}</div>
                <div class="desc">
                    <div>{{ pList?.date }}</div>
                    <div>{{ pList?.address }}</div>
                </div>
                <div class="price">
                    <span>售票中</span> <b>{{ pList?.wantNum }}</b>元
                </div>
            </div>
        </div>
        <template #right>
            <van-button square text="删除" type="danger" class="delete-button" @click="delWantBtn(pList.id)"/>
        </template>
    </van-swipe-cell>
</template>

<style lang="scss" scoped>
.want-play-item{
    width: 100vw;
    padding: 0 4vw;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 4vw 0;

    img{
        width: 26vw;
        height: 34vw;
        border-radius: 2vw;
    }
    .con{
        color: #666;
        font-size: 14px;
        width: 62vw;
        height: 34vw;
        line-height: 6vw;
        display: flex;
        flex-wrap: wrap;
        align-content: space-between;
        
        .name{
            color: #222;
            font-size: 16px;
            font-weight: bold;
        }
        .desc{
            div{
                width: 62vw;
                white-space: nowrap;
                text-overflow: ellipsis;
                overflow: hidden;
            }
        }
        .price{
            color: #222;
            display: flex;
            align-items: center;

            span{
                color: #fb3435;
                display: inline-block;
                padding: 0 2px;
                background-color: #fdeff1;
                margin-right: 1vw;
            }
        }
    }
}
.delete-button{
    height: 34vw;
}
</style>